﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Icedream.InstantFileTransfer
{
    /// <summary>
    /// Represents a file served on an IFTPServer
    /// </summary>
    public class IFTPListFile
    {
        internal string _name;
        internal long _size;
        internal string _code;

        /// <summary>
        /// Gets the file name of the list entry
        /// </summary>
        public string Name
        {
            get { return _name; }
        }

        /// <summary>
        /// Gets the file size of the list entry
        /// </summary>
        public long Size
        {
            get { return _size; }
        }

        /// <summary>
        /// Gets the file's download code
        /// </summary>
        public string Code
        {
            get { return _code; }
        }

        #region Exception generators
        internal void ExceptionOnInvalidFilename()
        {
            if (_name.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
                throw new InvalidFilenameException();
        }
        internal void ExceptionOnInvalidFilesize()
        {
            if (_size < 0)
                throw new InvalidFilesizeException();
        }
        #endregion

        internal IFTPListFile(string filename, long filesize, string filecode)
        {
            this._name = filename;
            this._size = filesize;
            this._code = filecode;
        }

    }
}
